package com.tt.dp.state;

public class SoldState implements State{

    private GumballMachine gumballMachine;

    public SoldState(GumballMachine gumballMachine) {
        this.gumballMachine = gumballMachine;
    }

    public void insertQuarter() {
        System.out.println("please wait ,we're already giving you a gumball");
    }

    public void ejectQuarter() {
        System.out.println("sorry ,you already turned the crank");

    }

    public void turnCrank() {
        System.out.println("turning twice doesn't get you another gumball!");
    }

    public void dispense() {
        gumballMachine.releaseBall();

        if(gumballMachine.getCount() > 0){
            gumballMachine.setState(gumballMachine.getNoQuarterState());
        }else{
            System.out.println("oops ,out of gumballs!");
            gumballMachine.setState(gumballMachine.getSoldOutState());
        }
    }
}
